Skip to content
This repository has been archived by the owner on Feb 17, 2018. It is now read-only.

tonybolzan/yii-select2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Select2 for Yii

Wrapper Widget to use jQuery Plugin Select2 in Yii application.

Select2 script: https://github.com/ivaynberg/select2

Installation

Download or clone this repository and paste in /protected/extensions/select2

Usage

In your source code

Yii::import('ext.select2.Select2');

Or in config

    ...
    'import' => array(
        ...
        'ext.select2.Select2',
        ...
    ),
    ...

Example:

You can replace the
CHtml::dropDownList() by Select2::dropDownList()
CHtml::activeDropDownList() by Select2::activeDropDownList()

Or

    ...
    echo Select2::multiSelect("test", null, array('test1','test2'), array(
        'required' => 'required',
        'placeholder' => 'This is a placeholder',
        'select2Options' => array(
            'maximumSelectionSize' => 2,
        ),
    ));
    ...
    echo Select2::activeMultiSelect($model, "attr", array('test1','test2'), array(
        'placeholder' => 'This is a placeholder',
    ));
    ...

Or this

    ...
    $this->widget('Select2', array(
       'name' => 'inputName',
       'value' => 2,
       'data' => array(
           1 => 'Option 1',
           2 => 'Option 2',
           3 => 'Option 3',
           4 => 'Option 4',
        ),
    ));
    ...

About

Wrapper Widget to use jQuery Select2 in Yii application.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published